import requests
import re
import urllib3

from requests.auth import HTTPBasicAuth
from requests_oauthlib import OAuth1
"""
r = requests.get('https://www.httpbin.com/get')
# print(r.text)

data = {
    'name': 'lucy',
    'age': 25
}
# r = requests.get('https://www.httpbin.com/get', params=data)
print(r.text)
print(type(r.text))
print('------------------------')
# print(r.json()) # 报错

"""

"""
req = requests.get('https://ssr1.scrape.center/')
pattern = re.compile('<h2.*?>(.*?)</h2>', re.S)
titles = re.findall(pattern, req.text)
print(titles)

"""

"""
req = requests.get('https://scrape.center/favicon.ico')
print(req.text)
print(req.content)

with open('favicon.ico', 'wb') as f:
    f.write(req.content)
"""

"""
data = {
    'name': 'lucy',
    'age': 25
}
req = requests.post('https://www.httpbin.org/post', data=data)
print(req.text)
"""

"""
req = requests.get('https://ssr1.scrape.center/')
print(type(req.status_code), req.status_code)
print(type(req.headers), req.headers)
print(type(req.cookies), req.cookies)
print(type(req.url), req.url)
print(type(req.history), req.history)
"""

"""
r = requests.get('https://www.baidu.com/')
print(r.cookies)
for key, value in r.cookies.items():
    print(key + '=' + value)
"""

"""
headers = {'Cookie':
               'user_locale=zh-CN; oschina_new_user=false; sensorsdata2015jssdkchannel=%7B%22prop%22%3A%7B%22_sa_channel_landing_url%22%3A%22%22%7D%7D; remote_way=http; yp_riddler_id=817474cd-2974-4e4d-abfc-e3210342638e; slide_id=10; Hm_lvt_dbba4dc235af9a121ecb9ae949529239=1698205074; BEC=1f1759df3ccd099821dcf0da6feb0357; csrf_token=ukLNo3OAcQCP5SLRRFwImbSqPsuau9Fv35lcgJalqFgGOoUCt9VqvD7Q6esksRxXh5l1LDnuTwpVlzUJqxHkGQ%3D%3D; Hm_lvt_24f17767262929947cc3631f99bfd274=1699324021,1699516620,1699847977,1700183599; user_return_to_0=%2F; tz=Asia%2FShanghai; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2218bdad6ee1f14b2-0895704d89963a8-26031051-2359296-18bdad6ee202259%22%2C%22first_id%22%3A%22%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%2C%22%24latest_utm_source%22%3A%22gitee_search%22%7D%2C%22identities%22%3A%22eyIkaWRlbnRpdHlfY29va2llX2lkIjoiMThiMjcyYmJkOWI1ODEtMDE2N2NkZmU3NDcyNTZmLTI2MDMxZTUxLTIzNTkyOTYtMThiMjcyYmJkOWNmYWEiLCIkaWRlbnRpdHlfbG9naW5faWQiOiIxMTg4MDc4NyJ9%22%2C%22history_login_id%22%3A%7B%22name%22%3A%22%24identity_login_id%22%2C%22value%22%3A%2211880787%22%7D%2C%22%24device_id%22%3A%2218b272bbd9b581-0167cdfe747256f-26031e51-2359296-18b272bbd9cfaa%22%7D; Hm_lpvt_24f17767262929947cc3631f99bfd274=1700183601; gitee_user=true; gitee-session-n=TWxTUGg5NlJRWkNjYWF5QzdzdTZpQ3NOa0JYdW9VeTQ2elNlN3RKNURvM2JDaTFJTTFOMmRlak1jK2h0ajZrUm5SaUl5Yitxclp4RGgxRko0M3dSUlo3bjhHbEVqeE1PZFc5Tk5veCtLdjJrY0JWeHptV3pGamZTNFg3WkdVTzJBUFEwM1Zsbm5PSldkY2pobTRmdUhKSUFSVU1PMmloREwwaVNpV2dJeHhBK1Y3anh3bHNSeUtRVVVVM3hsZDBUdWI4VXBUZzBRNFNUQVZVWG5xRmt3TGM1d1p4Myt1NzBJaDNZdi94ZUdpd1krd282bktCOE0yN091VFFOeEI3NHBnc3pGditWUS9MUzFORmdRbHJiMGlCZ3FoN2ZhZHRQUThWWHl4Q0dtMmtxZ3NGbjlNVTkrakQrdVpVTzQ4TUhqSEVVb3BqU0FScUhXd1U0N0NWV3hOUHhiN1BtaEEvMzNsMGs3SGQ3UlpySGRFYzJGVi82bFJIT3RieHBEcHhnY0VUTHZkUEQ2SmovOW83Wkk2UmhSVmFCd3FIei8wVnZlckJCaXVEQXdzTHprdCsyOW54NHl0LzNvMUxZaFF1WTZRS2RSN1BaRnQyWlFwMFoveVYvVnBDSVdzU20yb2ZzeUNhaXQ3WjE0RENaUW80UDN6Ujhwb3pWR3c4aG9ZQ3IzMjNNSldBOHNNb1NhMzB6NWVZdkdxNWFyYXpRSWR6c01sNW1zQ2dLRzBZPS0tWGVYaFVPVjR0ZGl1UzBtWitFRS9zUT09--21e54af0ce2891bc3cb7c749cd008e46c1c7621e'}

r = requests.get('https://gitee.com/', headers=headers)
print(r.text)
"""

"""
requests.get('https://www.httpbin.org/cookies/set/number/123456789')
r = requests.get('https://www.httpbin.org/cookies')
print(r.text)


s = requests.Session()
s.get('https://www.httpbin.org/cookies/set/number/123456789')
r = s.get('https://www.httpbin.org/cookies')
print(r.text)
"""

"""
# 请求失败  有些网站可能并没有设置好HTTPS证书
res = requests.get('https://ssr2.scrape.center/')
print(res.status_code)

"""

"""
# 忽略警告
urllib3.disable_warnings()
res = requests.get('https://ssr2.scrape.center/', verify=False)
print(res.status_code)
"""

"""
# 如果想永久等待,可以直接将timeout设置为None，或者不设置直接留空，因为默认取值是None。
#  超时时间设置为1秒，意味着如果1秒内没有响应，就抛出异常
r = requests.get('https://www.httpbin.org/get', timeout=1)
print(r.status_code)

"""


"""
# 账号密码
# res = requests.get('https://ssr3.scrape.center/', auth=HTTPBasicAuth('admin','admin'))
res = requests.get('https://ssr3.scrape.center/', auth=('admin', 'admin'))
print(res.status_code)
"""

# url =
